/**
 * 
 */
package org.chengsen.dao;

import javax.annotation.PostConstruct;

import org.chengsen.dataobject.UserDO;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * @author Jason.zhang
 * 
 */
@Repository
public class HibernateUserDAOImpl extends HibernateDaoSupport implements
		UserDAO {
	@Autowired
	private SessionFactory sessionFactory;

	@Override
	public UserDO getUser(Integer id) {
		return this.getHibernateTemplate().load(UserDO.class, 1);
	}

	@Override
	public void addUser(UserDO userDO) {
		this.getHibernateTemplate().save(userDO);
	}

	@PostConstruct
	public void init() {
		setSessionFactory(sessionFactory);
	}

}
